package day021.tcp.demo5;

import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.*;
import java.net.Socket;

public class TcpClient {
    private static final Logger LOGGER= LoggerFactory.getLogger("TcpClient客户端");

    public static void main(String[] args) throws IOException {
        Socket client=new Socket("127.0.0.1",9090);
        FileInputStream fis=new FileInputStream("D:\\ideaProjects\\javase_code\\study-practice\\src" +
                "\\day021\\tcp\\files\\123.jpg");

        OutputStream fos=client.getOutputStream();

        IOUtils.copy(fis,fos);
        client.shutdownOutput();
        LOGGER.trace("文件发送完毕！");

        BufferedReader br=new BufferedReader(new InputStreamReader(client.getInputStream()));
        String msg=br.readLine();
        LOGGER.trace("接收到服务器的消息："+msg);
    }
}
